if (ENABLE_MAPADMIN) then

local function AdminSay( ply, text, toall )
	local GM = gmod.GetGamemode()
	if ply:IsAdmin() and string.sub(text, 1, 7) == "!admin " then
		if not GM.MapFile then GM.MapFile = {} end
		if not GM.MapFile["weapons"] then GM.MapFile["weapons"] = {} end
		if not GM.MapFile["reload"] then GM.MapFile["reload"] = {} end
		local args = string.Explode(" ", text)
		if args[2] == "add" and args[3] and args[3] ~= "" then
			timer.Simple(0.1, function()
				local pos = ply:GetEyeTrace().HitPos + Vector(0,0,16)
				local ent = ents.Create(args[3])
				ent:SetPos(pos)
				ent:Spawn()
				ent:Activate()
				GM.MapFile["weapons"][table.Count(GM.MapFile["weapons"])] = args[3].." "..pos.x.." "..pos.y.." "..pos.z
				ply:ChatPrint("ADMIN: "..args[3].." added to weapons with parameters "..pos.x.." "..pos.y.." "..pos.z)
				file.Write("gjail/"..game.GetMap()..".txt", util.TableToKeyValues(GM.MapFile))
			end)
		elseif args[2] == "clean" then
			GM.MapFile["weapons"] = {}
			ply:ChatPrint("ADMIN: Weapons table have been cleaned up")
		end
		return false
	end
end
hook.Add( "PlayerSay", "GJail_AdminSay", AdminSay )

end